<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('服务端报文新增')"/>
</head>
<body>
<form action="" class="layui-form">
    <div class="mainBox">
        <div class="main-container">
            <div class="main-container">
                <div class="layui-form-item layui-hide">
                    <label class="layui-form-label">类型</label>
                    <div class="layui-input-block">
                        <input autocomplete="off" class="layui-input" lay-verify="required" name="busiType"
                               th:value="${busiType}" placeholder="请输入类型" type="text">
                    </div>
                </div>
                <div class="layui-form-item layui-hide">
                    <label class="layui-form-label">Http方法</label>
                    <div class="layui-input-block">
                        <select dict-code="msg_http_method" lay-verify="required" name="httpMethod"
                                default-value="POST">
                            <option value="">请选择</option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">渠道</label>
                    <div class="layui-input-block">
                        <select dict-code="msg_channel_no" lay-verify="required" name="channelNo" default-value="NONE">
                            <option value="">请选择</option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">报文编号</label>
                    <div class="layui-input-block">
                        <input autocomplete="off" class="layui-input" lay-verify="required" name="msgCode"
                               placeholder="请输入报文编号" type="text">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">报文名称</label>
                    <div class="layui-input-block">
                        <input autocomplete="off" class="layui-input" lay-verify="required" name="msgName"
                               placeholder="请输入报文名称" type="text">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">报文编码</label>
                    <div class="layui-input-block">
                        <select dict-code="msg_charset_name" lay-verify="required" name="charsetName"
                                default-value="UTF-8">
                            <option value="">请选择</option>
                        </select>
                    </div>
                </div>
                <label class="layui-form-label">报文头策略</label>
                <div class="layui-input-block">
                    <select dict-code="msg_head_strategy" lay-verify="required" name="headStrategy" default-value="00">
                        <option value="">请选择</option>
                    </select>
                </div>
            </div>
            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">报文内容</label>
                <div class="layui-input-block">
                                    <textarea class="layui-textarea" style="min-height: 200px" lay-verify="required"
                                              name="msgContent" placeholder="请输入报文内容"></textarea>
                </div>
            </div>
            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">描述</label>
                <div class="layui-input-block">
                    <textarea class="layui-textarea" name="remark" placeholder="请输入描述"></textarea>
                </div>
            </div>
        </div>
    </div>
    </div>
    <div class="bottom">
        <div class="button-container">
            <button class="pear-btn pear-btn-primary pear-btn-sm" lay-filter="msg-save" lay-submit=""
                    type="submit">
                <i class="layui-icon layui-icon-ok"></i>
                提交
            </button>
            <button class="pear-btn pear-btn-sm" type="reset">
                <i class="layui-icon layui-icon-refresh"></i>
                重置
            </button>
        </div>
    </div>
</form>
<th:block th:include="include :: footer"/>
<script>
    layui.use(['form', 'jquery', 'dictionary'], function () {
        let form = layui.form;
        let $ = layui.jquery;

        form.on('submit(msg-save)', function (data) {
            $.ajax({
                url: '/sim/msg/save',
                data: JSON.stringify(data.field),
                dataType: 'json',
                contentType: 'application/json',
                type: 'post',
                success: function (result) {
                    if (result.success) {
                        layer.msg(result.msg, {icon: 1, time: 1000}, function () {
                            parent.layer.close(parent.layer.getFrameIndex(window.name));//关闭当前页
                            parent.layui.table.reload("msg-table");
                        });
                    } else {
                        layer.msg(result.msg, {icon: 2, time: 1000});
                    }
                }
            })
            return false;
        });
    })
</script>
</body>
</html>